#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include<stdlib.h>

typedef struct BinaryTreeNode
{
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
    char val;
}BTNode;

BTNode* CreateTree(char* str, int* pi)
{
    if (str[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }

    BTNode* root = (BTNode*)malloc(sizeof(BTNode));
    root->val = str[*pi];
    (*pi)++;

    root->left = CreateTree(str, pi);
    root->right = CreateTree(str, pi);

    return root;
}

void InOrder(BTNode* root)
{
    if (root == NULL)
    {
        return;
    }
    InOrder(root->left);
    printf("%c ", root->val);
    InOrder(root->right);
}

int main() {
    char str[100];
    scanf("%s", str);
    int i = 0;
    BTNode* root = CreateTree(str, &i);
    InOrder(root);
    return 0;
}